package cn.micro.micronumberservice.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class Result {
    private int resultCode;
    private String resultMessage;
    private Object resultData;

    public static Result success() {
        Result result = new Result();
        result.resultCode = ResultEnum.SUCCESS.getCode();
        result.resultMessage = ResultEnum.SUCCESS.getMessage();
        return result;
    }

    public static Result success(String resultMessage, Object data) {
        Result result = new Result();
        result.resultCode = ResultEnum.SUCCESS.getCode();
        result.resultMessage = resultMessage;
        result.resultData = data;
        return result;
    }

    public static Result success(int resultCode, String resultMessage, Object data) {
        Result result = new Result();
        result.resultCode = resultCode;
        result.resultMessage = resultMessage;
        result.resultData = data;
        return result;
    }

    public static Result success(Object data) {
        Result result = new Result();
        result.resultCode = ResultEnum.SUCCESS.getCode();
        result.resultMessage = ResultEnum.SUCCESS.getMessage();
        result.resultData = data;
        return result;
    }

    public static Result error() {
        Result result = new Result();
        result.resultCode = ResultEnum.ERROR.getCode();
        result.resultMessage = ResultEnum.ERROR.getMessage();
        return result;
    }

    public static Result error(Object data) {
        Result result = new Result();
        result.resultCode = ResultEnum.ERROR.getCode();
        result.resultMessage = ResultEnum.ERROR.getMessage();
        result.resultData = data;
        return result;
    }


}
